<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fnx" uri="http://java.sun.com/jsp/jstl/functionsx" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="f" uri="http://www.sctv.com/tags/form" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="/WEB-INF/views/head.jsp"/>
    <script type="text/javascript">
      $(function () {
        $("#validForm").validate();
        $("input[name='userName']").focus();

          //相关新闻显示篇数
          function getJsonLength(jsonData){
              var jsonLength = 0;
              for(var item in jsonData){
                  jsonLength++;
              }
              return jsonLength;

          }
          var personrelateJsonStr='${bean.personRelateNews}';
          var count1=0
          if(personrelateJsonStr!="" && personrelateJsonStr!=null){
              var personrelateNewJson=JSON.parse('${bean.personRelateNews}');
              count1=getJsonLength(personrelateNewJson);
          }
          $("#personNewsIdName").val(count1+"篇");
      });

      function  checkData(){
        var personrelateNews=$("#personNewsIdName").val();
          var num=0;
          debugger;
          if(personrelateNews!=null && personrelateNews!='' ){
              num=personrelateNews.substr(0,personrelateNews.length-1);
              if(num!='1'){
                  alert("简历必须关联一条新闻");
                  return false;
              }
          }

      }
    </script>
</head>
<body class="skin-blue content-body">
<jsp:include page="/WEB-INF/views/commons/show_message.jsp"/>
<div class="content-header">
    <h1><s:message code="gc"/> - <s:message code="${oprt=='edit' ? 'edit' : 'create'}"/></h1>
</div>

<div class="content">
    <div class="box box-primary">
        <form class="form-horizontal" id="validForm" action="${oprt=='edit' ? 'update' : 'save'}.do" method="post" onsubmit="return checkData();">
            <tags:search_params/>
            <f:hidden name="id" value="${bean.id}"/>
            <input type="hidden" id="redirect" name="redirect" value="edit"/>
            <div class="box-header with-border">
                <div class="btn-toolbar">
                    <div class="btn-group">
                        <button class="btn btn-default" type="button"
                                onclick="location.href='list.do?${searchstring}';"><s:message code="return"/></button>
                    </div>
                </div>
            </div>
            <div class="box-body">
                <div class="row">

                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><em class="required">*</em><s:message code="gc.userName"/></label>
                            <div class="col-sm-8">
                                <f:text class="form-control required" name="userName"
                                        value="${oprt=='edit' ? (bean.userName) : ''}" maxlength="100"/>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><em class="required">*</em><s:message
                                    code="gc.position"/></label>
                            <div class="col-sm-8">
                                <f:text class="form-control" id="position" name="position"
                                        value="${oprt=='edit' ? (bean.position) : ''}" maxlength="100"/>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label"><em class="required">*</em>头像地址</label>
                                    <div class="col-sm-10">
                                        <script>
                                            function fn_smallImage(src) {
                                                Cms.scaleImg("img_smallImage", 200, 100, src);
                                            };
                                        </script>
                                        <div style="display:table;width:100%;">
                                            <div style="display:table-cell;vertical-align:middle;">
                                                <div class="input-group">
                                                    <span class="input-group-addon">地址</span>
                                                    <input type="text" id="smallImage" name="images"
                                                           value="${bean.images}"
                                                           onchange="fn_smallImage(this.value);" class="form-control ">
                                                </div>
                                                <div class="form-inline" style="margin-top:3px;">
                                                    <button class="btn btn-default" type="button" id="smallImageButton">选择
                                                    </button>
                                                    <object id="SWFUpload_0" type="application/x-shockwave-flash"
                                                            data="/static/vendor/swfupload/swfupload.swf?preventswfcaching=1502702265304"
                                                            width="54" height="34" class="swfupload">
                                                        <param name="wmode" value="transparent">
                                                        <param name="movie"
                                                               value="/static/vendor/swfupload/swfupload.swf?preventswfcaching=1502702265304">
                                                        <param name="quality" value="high">
                                                        <param name="allowScriptAccess" value="always">
                                                        <param name="flashvars"
                                                               value="movieName=SWFUpload_0&amp;uploadURL=%2Fcmscp%2Fcore%2Fupload_image.do%3Bjsessionid%3DB7EED2164EABD024D9BFE3361803971D%3F_site%3D&amp;useQueryString=false&amp;requeueOnError=false&amp;httpSuccess=&amp;assumeSuccessTimeout=0&amp;params=&amp;filePostName=file&amp;fileTypes=*.*&amp;fileTypesDescription=Images&amp;fileSizeLimit=0&amp;fileUploadLimit=0&amp;fileQueueLimit=0&amp;debugEnabled=false&amp;buttonImageURL=&amp;buttonWidth=54&amp;buttonHeight=34&amp;buttonText=&amp;buttonTextTopPadding=0&amp;buttonTextLeftPadding=0&amp;buttonTextStyle=color%3A%20%23000000%3B%20font-size%3A%2016pt%3B&amp;buttonAction=-100&amp;buttonDisabled=false&amp;buttonCursor=-2">
                                                    </object>
                                                    <button class="btn btn-default" type="button">上传</button>
                                                    <div style="display: none">
                                                        <button class="btn btn-default" type="button" id="smallImageSwfCancel"
                                                                onclick="smallImageSwfUpload.cancelQueue();" disabled="">取消
                                                        </button>
                                                    </div>

                                                </div>

                                                <input type="hidden" id="t_smallImage" value="false">
                                                <input type="hidden" id="tw_smallImage" value="116">
                                                <input type="hidden" id="th_smallImage" value="77">
                                            </div>
                                            <div style="width:200px;display:table-cell;vertical-align:middle;text-align:center;">
                                                <img id="img_smallImage" style="display:none;">
                                            </div>
                                        </div>
                                        <div id="smallImageSwfProgress"></div>
                                        <script>
                                            var smallImageSwfUpload = Cms.swfUploadImage("smallImage", {
                                                jsessionid: "B7EED2164EABD024D9BFE3361803971D",
                                                file_size_limit: "0",
                                                file_types: "*.*"
                                            });
                                            $(function () {
                                                Cms.f7.uploads("smallImage", "smallImage", {
                                                    settings: {"title": "选择附件"},
                                                    callbacks: {
                                                        "ok": function (src) {
                                                            fn_smallImage(src);
                                                        }
                                                    }
                                                });
                                            });
                                        </script>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>

                    <div class="col-sm-12">
                        <div class="form-group">
                        <label class="col-sm-2 control-label"><em class="required">*</em>简历关联新闻</label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <f:text  id="personNewsIdName" class="form-control" value="${bean.personRelateNews}" disabled="true"/>
                                <f:hidden id="personNewsId" name="personRelateNews" value="${bean.personRelateNews}"/>
                                <span class="input-group-btn">
							   		<button class="btn btn-default" id="personNewsIdButton" type="button">选择</button>
							    </span>
                            </div>
                        </div>
                        </div>
                    </div>
                    <script type="text/javascript">
                            $(function() {
                                Cms.f7.chooseRelatednews("personNewsId","personNewsIdName",'${bean.id}',{
                                    settings: {"title": "选择相关新闻"}
                                });
                            });
                    </script>
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><em class="required">*</em>专题</label>
                            <div class="col-sm-8">
                        <c:if test="${not empty bean.special}">
                            <f:hidden id="specialId" name="specialId" value="${bean.special.id}"/>
                            <div class="input-group">
                                <f:text class="form-control" id="specialIdTitle" value="${bean.special.title}" readonly="readonly"/>
                                <span class="input-group-btn">
                                      <button class="btn btn-default" id="specialIdButton" type="button">选择专题</button>
                                      <button class="btn btn-default" onclick="clearParentSpec()" type="button">清除</button>
                                  </span>
                            </div>
                        </c:if>
                        <c:if test="${empty bean.special}">
                            <f:hidden id="specialId" name="specialId" value=""/>
                            <div class="input-group">
                                <f:text class="form-control" id="specialIdTitle" value="" readonly="readonly"/>
                                <span class="input-group-btn">
                                      <button class="btn btn-default" id="specialIdButton" type="button">选择专题</button>
                                      <button class="btn btn-default" onclick="clearParentSpec()" type="button">清除</button>
                                      </span>
                            </div>
                        </c:if>
                            </div>
                        </div>
                    </div>
                        <script type="text/javascript">
                            $(function(){

                                $(function() {
                                    Cms.f7.infospec("specialId","specialIdTitle",{
                                        settings: {"title": "选择专题"}
                                    });
                                });
                            });
                        </script>
                    <div class="col-sm-6">
                        <div class="form-group">
                            <div id="filesContainer" style="display: none"></div>
                        </div>
                    </div>
                </div>
            </div>
            <script type="text/javascript">
              function SetChannel() {
                var url = "";
                $("#filesContainer input[name='filesFile']").each(function () {
                  var u = $(this).val();
                  url += u + ',';
                });
                $('#channelMove').val(url);
              }
            </script>
            <div class="box-footer">
                <button class="btn btn-default" type="submit"  onclick="$('#redirect').val('list');"
                        onmouseover="SetChannel()"><s:message
                        code="saveAndReturn"/></button>
            </div>
        </form>
    </div>
</div>
</body>
</html>